import {
	apiGetServerList,
	apiPostServerList
}  from './apiServerList';

export const computedPostDictionarySearch = (ev) => {/*获取业务类型*/
			 apiPostServerList(
			 	'dictionary/search',{"type":"business_type"}
			 ).then((res)=>{
			 	if(res.data.code==='S100101'){
			 		ev.menuLi = res.data.data.list;
			 		ev.businessId = res.data.data.list[0].id;
			 	}
			 })

};

export const computedPostDictionarySearchInfo = (ev) => {/*获取信息类型*/
			 apiPostServerList(
			 	'dictionary/search',{"type":"info_type"}
			 ).then((res)=>{
			 	if(res.data.code==='S100101'){
			 		ev.collectTab = res.data.data.list
			 		ev.shareTab = res.data.data.list
			 		for (let i = 0; i < ev.collectTab.length; i++) {
			 			ev.collectTab[i].items=[];
			 			ev.shareTab[i].items=[];
			 		}
			 	}
			 })

};

export const computedPostResourceService = (ev,param,index) => {/*资源类型*/
			 ev.show=false;
			 apiPostServerList(
			 	'resource/service/search',param
			 ).then((res)=>{
			 	if(res.data.code==='S100101'){
			 		if(res.data.data.list.length!=0){/*有数据*/
			 			if(param.serviceType==1){
			 				ev.shareTab[index].items=[];
			 				ev.shareTab[index].items = res.data.data.list;
			 			}else if(param.serviceType==2){
			 				ev.collectTab[index].items=[];
			 				ev.collectTab[index].items=res.data.data.list;
			 			}
			 			ev.show=true;
			 		}else{/*无数据*/
			 			if(param.serviceType==1){
			 				ev.shareTab[index].items=[];
			 				ev.shareTab[index].items.push({
			 					id:0,
			 					name:'无数据'
			 				})
			 				ev.shareTab[index].show=true
			 			}else if(param.serviceType==2){
			 				ev.collectTab[index].items=[];
			 				ev.collectTab[index].items.push({
			 					id:0,
			 					name:'无数据'
			 				})
			 			}
			 			ev.show=true;
			 		}
			 	}
			 })

};


export const computedPostServiceSearch=(ev,name)=>{
	apiPostServerList(
		'resource/service/search',{
			"name":name
		}
	).then((res)=>res)
}
